package com.example.demo.dao.daoimpl;

import com.example.demo.dao.GoodsDao;
import com.example.demo.entity.Goods;
import com.example.demo.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;

import java.util.List;

public class GoodsDaoImpl implements GoodsDao {
    @Override
    public List<Goods> goodsList() {
        Session session= HibernateUtil.openSession();
        Transaction tx=session.beginTransaction();
        String hql="from Goods";
        List<Goods> goods=session.createQuery(hql,Goods.class).list();
        System.out.println("========================="+goods.size());
        tx.commit();
        HibernateUtil.closeSession();
        return goods;
    }
}
